#ifndef CSBBELLE_RUNINFOROW_HPP_
#define CSBBELLE_RUNINFOROW_HPP_

#include <vector>

#include <hdf5.h>

struct csbbelle_runinforow_t {
  public:
    float beam_e;
    float boost_x;
    float boost_y;
    float boost_z;
    float cross_angle;
    float e_her;
    float e_ler;
    int expno;
    float init_e;
    float init_px;
    float init_py;
    float init_pz;
    int runno;

    static std::vector<hid_t> field_types() {
      static std::vector<hid_t> types;

      if (types.size() == 0) {
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_INT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_INT);
      }

      return types;
    }

    static std::vector<std::string> field_names() {
      static std::vector<std::string> fields;

      if (fields.size() == 0) {
        fields.push_back("beam_e");
        fields.push_back("boost_x");
        fields.push_back("boost_y");
        fields.push_back("boost_z");
        fields.push_back("cross_angle");
        fields.push_back("e_her");
        fields.push_back("e_ler");
        fields.push_back("expno");
        fields.push_back("init_e");
        fields.push_back("init_px");
        fields.push_back("init_py");
        fields.push_back("init_pz");
        fields.push_back("runno");
      }

      return fields;
    }

    static hid_t h5_type() {
      static hid_t type_id = 0;

      if (type_id == 0) {
        type_id = H5Tcreate(H5T_COMPOUND, sizeof(csbbelle_runinforow_t));

        H5Tinsert(type_id, "beam_e", HOFFSET(csbbelle_runinforow_t, beam_e), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "boost_x", HOFFSET(csbbelle_runinforow_t, boost_x), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "boost_y", HOFFSET(csbbelle_runinforow_t, boost_y), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "boost_z", HOFFSET(csbbelle_runinforow_t, boost_z), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "cross_angle", HOFFSET(csbbelle_runinforow_t, cross_angle), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "e_her", HOFFSET(csbbelle_runinforow_t, e_her), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "e_ler", HOFFSET(csbbelle_runinforow_t, e_ler), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "expno", HOFFSET(csbbelle_runinforow_t, expno), H5T_NATIVE_INT);
        H5Tinsert(type_id, "init_e", HOFFSET(csbbelle_runinforow_t, init_e), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "init_px", HOFFSET(csbbelle_runinforow_t, init_px), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "init_py", HOFFSET(csbbelle_runinforow_t, init_py), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "init_pz", HOFFSET(csbbelle_runinforow_t, init_pz), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "runno", HOFFSET(csbbelle_runinforow_t, runno), H5T_NATIVE_INT);
      }

      return type_id;
    }

    static const char* hbook_defstr() {
      return "beam_e boost_x boost_y\
              boost_z cross_angle e_her\
              e_ler expno init_e\
              init_px init_py init_pz\
              runno";
    }

};

csbbelle_runinforow_t csbbelle_runinforow_default = {
  -1.0, //beam_e
  -1.0, //boost_x
  -1.0, //boost_y
  -1.0, //boost_z
  -1.0, //cross_angle
  -1.0, //e_her
  -1.0, //e_ler
  -1, //expno
  -1.0, //init_e
  -1.0, //init_px
  -1.0, //init_py
  -1.0, //init_pz
  -1 //runno
};

#endif //CSBBELLE_RUNINFOROW_HPP_
